gsk: Pass texture coordinates to Vulkan renderer
authorBenjamin Otte <otte@redhat.com>
Mon, 5 Dec 2016 22:07:56 +0000 (23:07 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 9 Dec 2016 17:35:51 +0000 (18:35 +0100)
We just render the coordinates as color, we don't do anything with them
yet.

gsk/gskvulkanpipeline.c
gsk/gskvulkanrenderer.c
gsk/resources/vulkan/blit.frag.glsl
gsk/resources/vulkan/blit.frag.spv
gsk/resources/vulkan/blit.vert.glsl
gsk/resources/vulkan/blit.vert.spv

index 8da3f27b44a6727c2a4709f498f4164d37e76026..93f0cf71d31871a80aae996f3456f4c0f99eb2d6 100644 (file)
@@ -95,17 +95,23 @@ gsk_vulkan_pipeline_new (GdkVulkanContext *context,
                                                    .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) {
                                                        {
                                                            .binding = 0,
-                                                           .stride = 2 * sizeof(float),
+                                                           .stride = 4 * sizeof (float),
                                                            .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
                                                        }
                                                    },
-                                                   .vertexAttributeDescriptionCount = 1,
+                                                   .vertexAttributeDescriptionCount = 2,
                                                    .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) {
                                                        {
                                                            .location = 0,
                                                            .binding = 0,
                                                            .format = VK_FORMAT_R32G32_SFLOAT,
                                                            .offset = 0,
+                                                       },
+                                                       {
+                                                           .location = 1,
+                                                           .binding = 0,
+                                                           .format = VK_FORMAT_R32G32_SFLOAT,
+                                                           .offset = 2 * sizeof (float),
                                                        }
                                                    }
                                                },
index dddcc5a7ff000d66d7a79c0751c17af552b3b406..d8464497f281426cc4394065863c5e4a8e8dad71 100644 (file)
@@ -277,13 +277,13 @@ gsk_vulkan_renderer_do_render_commands (GskVulkanRenderer *self,
 {
   GskVulkanBuffer *buffer;
   float pts[] = {
-    -1.0, -1.0,
-    1.0, -1.0,
-    -1.0, 1.0,
+    -1.0, -1.0,  0.0, 0.0,
+     1.0, -1.0,  1.0, 0.0,
+    -1.0,  1.0,  0.0, 1.0,
 
-    -1.0, 1.0,
-    1.0, -1.0,
-    1.0, 1.0
+    -1.0,  1.0,  0.0, 1.0,
+     1.0, -1.0,  1.0, 0.0,
+     1.0,  1.0,  1.0, 1.0
   };
   guchar *data;
 
index 94f76e4f16ceb7ebe1a6a7ae328d34e6fba526b1..acc86807dd3a0174de87420a227063760638c471 100644 (file)
@@ -1,8 +1,10 @@
 #version 420 core
 
+layout(location = 0) in vec2 inTexCoord;
+
 layout(location = 0) out vec4 color;
 
 void main()
 {
-    color = vec4(1.0, 1.0, 0.0, 1.0);
+    color = vec4 (inTexCoord, 0.0, 1.0);
 }
index 76adb08511b6bdcfe10cd0a2162059122ee1a1f0..05fd46999761579f2fccfac3df43a2b6d53c7a1a 100644 (file)
Binary files a/gsk/resources/vulkan/blit.frag.spv and b/gsk/resources/vulkan/blit.frag.spv differ
index ae450004d2488f1007290c4bac9db418ef713f1d..38654054295c834f74c0b84851df7787bb06009e 100644 (file)
@@ -1,11 +1,15 @@
 #version 420 core
 
 layout(location = 0) in vec2 inPosition;
+layout(location = 1) in vec2 inTexCoord;
+
+layout(location = 0) out vec2 outTexCoord;
 
 out gl_PerVertex {
   vec4 gl_Position;
 };
 
 void main() {
-  gl_Position = vec4(inPosition, 0.0, 1.0);
+  gl_Position = vec4 (inPosition, 0.0, 1.0);
+  outTexCoord = inTexCoord;
 }
index 41ea691e5bffea8316a0a152b8a8fbfcf1f74172..66413971d487a02b58404452a55802fad4e79f59 100644 (file)
Binary files a/gsk/resources/vulkan/blit.vert.spv and b/gsk/resources/vulkan/blit.vert.spv differ